#!/usr/bin/env node

const Router = require('koa-router'),
      router = new Router(),
      //router = require('koa-router')(),
      tasks = require('../models/tasks'),
      log = console.log;

router.prefix('/api/tasks');

router.get('/',async(ctx,next) => {
  let res = await tasks.getAllTasks(ctx.userId);

  ctx.body = res;
});

router.post('/',async(ctx,next) => { 
  let {task} = ctx.request.body;

  log(`提交待办事项,task:${task}`);
  ctx.body = '添加成功';     
});

module.exports = router;
